package Day4.JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Jdbc {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String username = "root";
        String password = "123456";
        String url = "jdbc:mysql://localhost:3306/gui?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
        Connection connection = DriverManager.getConnection(url,username,password);
        Statement statement = connection.createStatement();
        String sql="select * from denglu";
        ResultSet resultSet = statement.executeQuery(sql);
        while(resultSet.next()){
            String name = resultSet.getString("name");
            System.out.println(name);
        }
        statement.close();
        connection.close();
    }
}
